<%@ page language="java" session="true" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<jsp:include page="../common/framework/header.jsp" />
<link href="${pageContext.request.contextPath}/static/plugin/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
<link href="${pageContext.request.contextPath}/static/css/testCase/corecss.css" rel="stylesheet">
<link href="${pageContext.request.contextPath}/static/css/zTreeStyle/zTreeStyle.css" rel="stylesheet">
<style type="text/css">
	.panel-body {
		padding-bottom:0px;
	}
	.tree_menu:hover {
		background-color: #D4E5F5;
	}
	.tree_menu {
		padding: 8px
	}
	.showAll_open {
		background-color: #D4E5F5;
	
	}

	select.form-control {
	    height: 32px;
	    padding: 4px 6px;
	    width: 102px!important;
	}
	.testPlan_right_title {
		padding:0;
	}
	.testPlan_right_title>h4 {
		display:inline;
	}
	.testPlan_right_title>a {
		margin-top: 10px;color:#fff;
	}
	.tdcolor {
		background-color: #eee
	}
	#gridTableDiv th {
   		background: #ddd;
	}
	#testPlan_grid {
		display:none;
		margin-top: 10px;
	}
	#testPlan_grid>a {
		color:#000;
	}
	#testPlan_grid>a:hover {
		color:#007acc;
		text-decoration: none;
	}
	.tdcolor {
		background: #f5f5f5;
	}
	.coodo-grid {
    table-layout: fixed;
    margin-bottom: 0;
    margin-left: 0;
}
.bs-bars {
    padding-right: 100px;
}
.fixed-table-pagination .page-list {
    display: none;
}
/* 	.bs-bars{padding:0;} */
	.drop {
    display: inline-block;
    position: relative;
    width: 16px;
    height: 16px;
    vertical-align: middle;
    overflow: hidden;
    background: url(${pageContext.request.contextPath}/static/_content/tfs-icons.png) no-repeat -1553px 50% !important;
}

.ztree li span.button.add {
	margin-left:2px;
	margin-right: -1px;
	background-position:-144px 0;
	vertical-align:top;
	*vertical-align:middle
}
.ztree li span.button.remove {
     margin-left: 1px;
	background-position: 0 0;
     vertical-align: top;
    background: url(${pageContext.request.contextPath}/static/_content/tfs-icons.png) no-repeat -1296px -16px !important;
}
div#rMenu {position:absolute; visibility:hidden; top:0; background-color: #fff;text-align: left;padding: 2px;}
div#rMenu ul li{
	margin: 1px 0;
	padding: 0 5px;
	cursor: pointer;
	list-style: none outside none;
	background-color: #fff;
	line-height: 25px;
}
div#rMenu ul li:hover{
	background-color: #dcebfc;
}
.bootstrap-table .fixed-table-toolbar .bs-bars {
    margin-top: 10px;
    margin-bottom: 10px;
}
A:hover {
    color: #26a0f5;
    text-decoration: none;
}
</style>
	<div id="container"
		class="effect aside-float aside-bright mainnav-lg navbar-fixed mainnav-fixed aside-fixed">

		<jsp:include page="../common/framework/topper.jsp" />
		<div class="boxed">
			<%--=======================  页面主体内容  ============================--%>
			<div id="content-container">
				<div class="wrappers">
					<%--=========================  页面标题  ==========================--%>
					<div id="page-title">
						<p class="page-header text-overflow table-header">
							测试计划&nbsp;&nbsp;<small>编辑测试计划。。。。详细说明请参考
							<a href="http://confluence.paas.sinopec.com/pages/viewpage.action?pageId=11343322#id-使用手册-_Toc4718118912" target="_blank">&lt;使用手册&gt;</a></small>
						</p>
					</div>
					<ol class="breadcrumb">
						<li><a href="#">项目管理</a></li>
						<li class="active">测试计划</li>
					</ol>
					<div id="page-content" class="form-horizontal">

						<div class="panel">
							<div class="panel-body pad-top-no">
								<div class="col-sm-3" style="border-right:1px solid #ccc;height:600px;">
										<div class="form-group row" style="margin-top: 20px;">
							            	<div class="col-xs-12" style="padding-right:0;padding-left:15px;">
												<select class=" form-control" id="testplanId" name="testplanId" style="width:93%!important;"onchange="testPlan_left.testplanIdChange('change');">
												</select>
											</div>
							         	</div>
							         	<hr style="margin-bottom:11px;">
                                        <div class="input-group-btn" style="display:inline;font-size:12px; ">
                                        	<a data-toggle="dropdown" class="tree_menu dropdown-toggle" type="button" id="createItem" title="创建" >
												<span class="icon icon-add-small"></span>
												<span class="drop"></span>
											</a>
                                            <ul class="dropdown-menu" style="margin-top:20px;">
                                                <li><a onclick="addTestPlanOrSuit(0)">创建测试计划</a></li>
                                                <li><a onclick="addTestPlanOrSuit(1)">创建测试套件</a></li>
                                            </ul>
                                        </div>
										<a class="tree_menu" type="button" onclick="openTestPlanOrSuite()" title="打开测试计划或套件">
												<span class="icon icon-open"></span>
										</a>
							         	<span style="margin-left:3px;color: #ccc">|</span>
							         	<a class="tree_menu" type="button" id="showAll" title="显示全部子信息">
												<span class="icon child-node-icon"></span>
										</a>
										<a class="tree_menu" type="button" id="expandAllBtn" title="全部展开">
												<span class="icon icon-tree-expand-all"></span>
										</a>
										<a class="tree_menu" type="button" id="collapseAllBtn" title="全部折叠">
												<span class="icon icon-tree-collapse-all"></span>
										</a>
										<hr style="margin-top:10px;">
										<div class="zTreeDemoBackground left" style="height:450px;overflow:auto;">
											<ul id="treeDemo" class="ztree"></ul>
										</div>
								</div>
								<div class="col-sm-9" >
									<div class ="panel-title testPlan_right_title">
										<h4>列表显示</h4>
										<a class="btn btn-primary pull-right" onclick="changeDisplay()">
											切换网格
										</a>
									</div>

									<hr style="margin:0;">
									<div id="testPlan_list">
										<div class="form-inline" style="margin-top:0;">
											<label class="control-label width-auto" style="margin-top: 10px;">结果:</label>
												<select class="form-control" id="resultId" name="resultId" onchange="testPlan_list.resultOnchange();"style="margin-top: 10px;">
													<option value="">全部</option>
													<option value="0">活动</option>
													<option value="1">通过</option>
													<option value="2">失败</option>
													<option value="3">阻止</option>
													<option value="4">不适用</option>
												</select>

												<label class="control-label width-auto" style="margin-top: 10px;">状态:</label>
												<select class="form-control" id="stateId" name="stateId" onchange="testPlan_list.stateOnchange();"style="margin-top: 10px;">
													<option value="">全部</option>
													<option value="1">就绪</option>
													<option value="2">设计</option>
													<option value="3">已关闭</option>
												</select>

												<label class="control-label width-auto" style="margin-top: 10px;">模块:</label>
												<select class="form-control" id="moduleId" name="moduleId" onchange="testPlan_list.moduleOnchange();"style="margin-top: 10px;">
												</select>

												<label class="control-label width-auto" style="margin-top: 10px;">指派人:</label>
												<select class="form-control" id="assignId" name="assignId" onchange="testPlan_list.assignerOnchange();"style="margin-top: 10px;">
												</select>

												<label class="control-label width-auto" style="margin-top: 10px;">创建人:</label>
												<select class="form-control" id="authorId" name="authorId" onchange="testPlan_list.authorOnchange();"style="margin-top: 10px;">
												</select>
												<a id = "reset" class = "btn btn-gray" onclick="testPlan_list.resetTable();"style="margin-top: 10px;"><i class="glyphicon glyphicon-share-alt"></i> 重置</a>
										</div>
										<hr style="margin-bottom: 10px;margin-top: 10px;">
										<div id="toolbar">
											<form id="search_form" class="form-inline" autocomplete="off">
												<a type="button" id="insert" style="padding-right:10px;">
													<i class="fa fa-plus"></i> 新建
												</a>
												<a type="button" onclick="addExistingTestCase()"style="padding-right:10px;">
													添加现有测试
												</a>
												<a type="button" id="insert" disabled="true" style="padding-right:10px;opacity:0.5; cursor:default; pointer-events:none">
													关联需求
												</a>
<!-- 												<a type="button" style="margin-right :5px;" title="创建bug" onclick="createBug();" class="add_case" id="createBug"> -->
<!-- 								         				<span class="fa fa-bug" style="margin-bottom:3px;color:#949494;"></span>  -->
<!-- 								         				创建bug -->
<!-- 								         		</a> -->
<!-- 												<a class="tree_menu" type="button" id="" title="保存测试用例"> -->
<!-- 														<span class="icon icon-save-all"></span> -->
<!-- 												</a> -->
												<a class="tree_menu" type="button" onclick="testPlan_list.updateTestCaseResult(0);" title="重置为活动的测试">
														<span class="icon icon-tfs-tcm-reset-active"></span>
												</a>
												<a class="tree_menu" type="button" onclick="testPlan_list.updateTestCaseResult(1);" title="通过测试">
														<span class="icon icon-tfs-build-status-succeeded"></span>
												</a>
												<a class="tree_menu" type="button" onclick="testPlan_list.updateTestCaseResult(2);" title="未通过测试">
														<span class="icon icon-tfs-build-status-failed"></span>
												</a>
												<a class="tree_menu" type="button" onclick="testPlan_list.updateTestCaseResult(3);" title="阻止测试">
														<span class="icon icon-tfs-tcm-block-test"></span>
												</a>
												<a class="tree_menu" type="button" onclick="testPlan_list.updateTestCaseResult(4);" title="不适用">
														<span class="icon icon-tfs-tcm-not-applicable"></span>
												</a>
											</form>
										</div>
	                                  <table id="testPlanTable" class="table" data-single-select="true" data-toolbar="#toolbar" data-show-refresh="true"
	               						data-show-columns="true"
	               						 data-buttons-class="hover-primary">
	                                      <thead>
									        <tr>
									            <th data-field="" data-checkbox="true"></th>
									            <th data-field="result" data-formatter="resultFormatter">结果</th>
									            <th data-field="name">用例名称</th>
									            <th data-field="state" data-formatter="stateFormatter">状态</th>
									            <th data-field="priority" >优先级</th>
<!-- 									            <th data-field="lasterOpertor" >上次执行者(待定)</th> -->
									            <th data-field="moduleNm" >模块</th>
									            <th data-field="authorNm" >创建人</th>
									            <th data-field="assignNm" >指派人</th>
									            <th data-align="center" data-width="140" data-formatter="pref_btns">操作</th>
									        </tr>
									    </thead>
	                                  </table>
								</div>

								<div id="testPlan_grid" >
										<a type="button" style="margin-right: 15px;" onclick="testPlan_grid.saveGridData();">
											<span class="icon icon-save-all"></span>
											保存
										</a>
										<a type="button" id="gridRefresh" onclick="testPlan_grid.gridRefresh();">
											<span class="icon icon-refresh-tfs"></span>
											刷新
										</a>
										<hr style="margin-top:10px;">
										<div id="gridTableDiv" class="shade" style="margin-top: 20px;height:400px; overflow:auto;">

											<table class="table table-bordered" onclick="testPlan_grid.doclick()">
												<thead>
													<tr>
														<th style="width:33.3%;">标题</th>
														<th style="width:33.3%;">步骤操作</th>
														<th style="width:33.3%;">预期结果</th>
													</tr>
												</thead>
												<tbody id="gridBody"></tbody>
											</table>

											<a type="button" class="btn btn-block btn-outline "
												onclick="testPlan_grid.appendRow();"> <font style='font-style: italic'>在此处单击以添加步骤</font>
											</a>
										</div>

								</div>


								</div>

							</div>
						</div>

					</div>
		</div>
	</div>

	<!--右键菜单的源-->
<div class="contextMenu" id="myMenu1" style="display: none">
		<ul>
			<li id="insert">插入行</li>
			<li id="delete">删除行</li>
			<li id="clear">清除行</li>
		</ul>
</div>
<div id="rMenu" style="border: 1px solid #ddd;width:200px;">
	<ul style="padding-left: 0;margin-bottom: 0;">
		<li id="m_add" onclick="testPlan_left.addTreeNode();"><span class="icon icon-tfs-tcm-static-suite"></span>&nbsp;&nbsp;新建测试套件</li>
		<li id="m_del" onclick="testPlan_left.removeTreeNode();"><span class="icon icon-delete"></span>&nbsp;&nbsp;删除</li>
		<li id="m_rename" onclick="testPlan_left.beforeEditName();"><span class="icon icon-rename"></span>&nbsp;&nbsp;重命名</li>
		<li id="m_open" onclick="openTestPlanOrSuite();"><span class="icon icon-open"></span>&nbsp;&nbsp;打开测试套件</li>
	</ul>
</div>

<div id ="addTestPlanOrSuitHtml" style="display:none;">
		<form id ="addTestPlanOrSuitForm">
	         <div class="row" style="padding-right:10px;margin:30px 0 0 0;">
		         <div class = "form-group col-sm-12 col-xs-12">
		            <label class="col-xs-2" style="padding:6px 0 0 0;text-align:right;"><font color=red>*</font>名称:</label>
		            <div class="col-xs-10" style="padding-right:0;">
		            	<input type="text" class=" form-control" id="planOrSuiteName" name="planOrSuiteName" placeholder = "请输入名称" >
		         	</div>
		         </div>
	         </div>
	    </form>
	</div>
		<%--=========================  过程可视化消息栏  ==========================--%>
		<jsp:include page="../common/framework/aside.jsp" />

		<%--=========================  左侧菜单  ==========================--%>
		<jsp:include page="../common/framework/lefter.jsp" />

	</div>

	<%--=========================  页面底部版权信息  ==========================--%>
	<jsp:include page="../common/framework/footer.jsp" />
	<%--=========================  选择皮肤功能  ==========================--%>
	<jsp:include page="../common/framework/page-set.jsp" />
</div>
	<div id="floating-top-right" class="floating-container"></div>
<%--===================================================--%>
<%-- END OF CONTAINER --%>

<jsp:include page="../common/framework/script.jsp" />
	<script src="${pageContext.request.contextPath}/static/js/common/bootdatatable.init.js"></script>
	<script src="${pageContext.request.contextPath}/static/plugin/bootstrap-table/bootstrap-table.min.js"></script>
	<script src="${pageContext.request.contextPath}/static/plugin/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>
	<script src="${pageContext.request.contextPath}/static/js/common/jquery.ztree.core.js"></script>
	<script src="${pageContext.request.contextPath}/static/js/common/jquery.ztree.excheck.js"></script>
	<script src="${pageContext.request.contextPath}/static/js/common/jquery.ztree.exedit.js"></script>
	<script src="${pageContext.request.contextPath}/static/js/common/jquery.contextMenu.js"></script>
	<script src="${pageContext.request.contextPath}/static/js/testPlan/testPlan.js"></script>

	<script type="text/javascript">
	var insertFlag = "testplan";
	var testplanLayerFlag = "";
	var globalAddFlag;
	var currentProjectId = '${currentProjectId}';
	$(function(){ 
    	$(document).keydown(function(event){ 
	    	if(event.keyCode==13){
	    		if(testplanLayerFlag == "addTestPlanOrSuit"){
	    			submitAddTestPlanOrSuit(globalAddFlag);
	    		}
	    	} 
    	}); 
});

	$(function(){
		/*表单验证  */
		//表单验证
			 $('#addTestPlanOrSuitForm').bootstrapValidator({
		   		   message: 'This value is not valid',
		           feedbackIcons: {
		        	   valid:'glyphicon glyphicon-ok',
		        	   invalid:'glyphicon glyphicon-remove',
		        	   validating:'glyphicon glyphicon-refresh'
		           },
		           excluded: [':disabled'],
		            fields: {
		            	planOrSuiteName :{
							message : '名称验证失败',
							validators : {
								notEmpty : {//非空验证：提示消息
									message : '名称不能为空'
								},
								stringLength: {/*长度提示*/
								    min: 1,
								    max: 100,
								    message: '名称长度必须在1到100个字之间'
								   }
							}
						}

		               }
		        });
		})
	/* =========================左侧树部分开始 =========================== */
	var zTree, rMenu;
	var textFlag = "list";
	var nodeTypeId;
	//定义查询树节点信息返回值中的nodeId
	var listTree_nodeId = "";
	var nodeName = "";
	var zNodes = [];
	var setting = {
			view: {
				showIcon: false,//设置 zTree 是否显示节点的图标。
				fontCss : {color:"#26a0f5"},//个性化文字样式，只针对 zTree 在节点上显示的<A>对象。
// 				addHoverDom: testPlan_left.addHoverDom,//用于当鼠标移动到节点上时，显示用户自定义控件
				removeHoverDom: testPlan_left.removeHoverDom,//用于当鼠标移出节点时，隐藏用户自定义控件
				selectedMulti: false//设置是否允许同时选中多个节点。
			},
			edit: {
				drag: {
					autoExpandTrigger: true,//拖拽时父节点自动展开是否触发 onExpand 事件回调函数
					prev: true,//拖拽到目标节点时，设置是否允许移动到目标节点前面的操作
					inner: true,//拖拽到目标节点时，设置是否允许成为目标节点的子节点。
					next: true//拖拽到目标节点时，设置是否允许移动到目标节点后面的操作。
				},
				enable: true,//设置 zTree 是否开启异步加载模式
				editNameSelectAll: true,//节点编辑名称 input 初次显示时,设置 txt 内容是否为全选状态
				showRemoveBtn: true,//设置是否显示删除按钮
				showRenameBtn: true//设置是否显示编辑名称按钮
			},
			data: {
				simpleData: {
					enable: true//确定 zTree 初始化时的节点数据、异步加载时的节点数据、或 addNodes 方法中输入的 newNodes 数据是否采用简单数据模式 (Array)
				}
			},
			callback: {
				beforeEditName: testPlan_left.beforeEditName,//判断是否允许编辑
				beforeRename: testPlan_left.beforeRename,//并且根据返回值确定是否允许更改名称的操作
				onRemove: testPlan_left.onRemove,//删除节点之后的回调
				onRename: testPlan_left.onRename,//用于捕获节点编辑名称结束之后的事件回调函数。
				onClick: testPlan_left.zTreeOnClick,//用于捕获节点被点击的事件回调函数
				onRightClick: testPlan_left.onRightClick,//用于捕获 zTree 上鼠标右键点击之后的事件回调函数
				beforeDrag: true,//用于捕获节点被拖拽之前的事件回调函数，并且根据返回值确定是否允许开启拖拽操作
				beforeDrop: testPlan_left.beforeDrop,
				beforeDragOpen: true,//用于捕获拖拽节点移动到折叠状态的父节点后，即将自动展开该父节点之前的事件回调函数，并且根据返回值确定是否允许自动展开操作
				onDrop: testPlan_left.onDrop//用于捕获节点拖拽操作结束的事件回调函数
				//onExpand: onExpand//用于捕获节点被展开的事件回调函数
			}
		};
		var newCount = 1;
		var addCount = 1;
	//展开选中节点下的所有子信息
	$("#showAll").click(function(){
		
		if($("#showAll").hasClass("showAll_open")){
			$("#showAll").removeClass("showAll_open");
			$(".testPlan_right_title>a").removeClass("disabled");
			showAll = false;
		}else{
			$("#showAll").addClass("showAll_open");
			$(".testPlan_right_title>a").addClass("disabled");
			showAll = true;
		}
		var params={
	            silent: true,
	            url:path+"/testCaseController/listTestCaseWithResult?nodeId="+nodeId
						+"&&showAll="+showAll+"&&result="+paramResult+"&&state="+state
						+"&&moduleId="+moduleId+"&&assignId="+assignId+"&&authorId="+authorId
	    };
		$('#testPlanTable').bootstrapTable('refresh',params);
		testPlan_list.listTestCaseWithResultPramList();
	});
	//创建测试计划或套件
	function addTestPlanOrSuit(addFlag){
		globalAddFlag = addFlag;
		$('#planOrSuiteName').val("");
		$('#addTestPlanOrSuitForm').data('bootstrapValidator').resetForm(true);
		var titleName;
		if(addFlag == 0){
			titleName = "新增测试计划";
		}else if(addFlag == 1){
			titleName = "新增测试套件";
		}
		layer.open({
			type : 1,
			title : titleName,
			fix : true,
			scrollbar : false,
//	 		maxmin: true, //开启最大化最小化按钮
			area : [ '500px', '220px' ],
			shift : 2,
			content : $('#addTestPlanOrSuitHtml'),
			btn:['确定','取消'],
			success: function(layero, index){
				if(!$('.layui-layer-title').has('span').length){
					 $(".layui-layer-title").prepend("<span class='glyphicon glyphicon-th-large' ></span>&nbsp;");
				 }
				testplanLayerFlag = "addTestPlanOrSuit";
		  	},
			end : function() {
				testplanLayerFlag = "";
			},
			yes: function(index, layero){
				submitAddTestPlanOrSuit(addFlag);
			  },
			btn2: function(index, layero){
			    //按钮【按钮二】的回调
			  },
		});
		};

	function submitAddTestPlanOrSuit(addFlag){
		var bootstrapValidator = $("#addTestPlanOrSuitForm").data('bootstrapValidator').validate();
    	if(bootstrapValidator.isValid()){
    		var name = $('#planOrSuiteName').val();
			if(addFlag == 0){
				testPlan_left.insertTestPlan(name);
			}else if(addFlag == 1){
				testPlan_left.insertTestSuite(name);
			}
    	}
	};

	/* =========================左侧树部分结束 =========================== */
	//初始化加载页面
	$(function(){
			testPlan_left.listTestPlan();
			testPlan_left.testplanIdChange();
			testPlan_list.listTestCaseWithResultPramList();
		});
	//网格列表切换触发事件
		function changeDisplay(){
			if(textFlag == "list"){
				textFlag = "grid";
				$(".testPlan_right_title>h4").text("网格显示");
				$(".testPlan_right_title>a").text("切换列表");
				$('#testPlan_list').hide();
				$('#testPlan_grid').show();
			}else if(textFlag == "grid"){
				textFlag = "list";
				$(".testPlan_right_title>h4").text("列表显示");
				$(".testPlan_right_title>a").text("切换网格");
				$('#testPlan_list').show();
				$('#testPlan_grid').hide();
			}
		}
		//打开测试计划或套件
		function openTestPlanOrSuite(){
			if(nodeTypeId == 1){
				openAndEditTestPlan();
			}else if(nodeTypeId == 2){
				openAndEditTestSuite();
			}else{
				toast.info ('请选择要打开的计划或套件！','信息提示');
			}
		}
		//打开测试计划编辑页
		var testPlanFreshFlag = 0;
		function openAndEditTestPlan(){

			layer.open({
				type : 2,
				title : '<span class="glyphicon glyphicon-th-large" ></span>&nbsp;测试计划编辑页',
				fix : true,
				scrollbar : false,
				area : [ '800px', '500px' ],
				shift : 2,
				content : '${pageContext.request.contextPath}/testPlanController/openAndEditTestPlan',
				btn: ['确定', '取消'],
					yes : function(index, layer) {
			            var iframeWin = layer.find('iframe')[0];
			            iframeWin.contentWindow.submit();
			        },
			        btn2:function(index, layer) {
			        },
				end : function(){
					if(testPlanFreshFlag == 1){
						var testplanId = $('#testplanId option:selected').val();
						testPlan_left.listTestPlan();
						$('#testplanId').val(testplanId);
						testPlanFreshFlag = 0;
					}
				}
			});
	};
	//打开测试套件编辑页
	var testSuiteFreshFlag = 0;
	function openAndEditTestSuite(){

		layer.open({
			type : 2,
			title : '<span class="glyphicon glyphicon-th-large" ></span>&nbsp;测试套件编辑页',
			fix : true,
			scrollbar : false,
			area : [ '720px', '500px' ],
			shift : 2,
			content : '${pageContext.request.contextPath}/testPlanController/openAndEditTestSuite',
			btn: ['确定', '取消'],
				yes : function(index, layer) {
		            var iframeWin = layer.find('iframe')[0];
		            iframeWin.contentWindow.submit();
		        },
		        btn2:function(index, layer) {
		        },
			end : function(){
				if(testSuiteFreshFlag == 1){
					var testplanId = $('#testplanId option:selected').val();
					testPlan_left.listTreeOnTestPlan(testplanId);
					testPlan_left.initZtree();
					testSuiteFreshFlag = 0;
				}
			}
		});
};
		/* =========================列表部分开始 =========================== */
		var testplanId = '${testPlanId}';
		var nodeId = "";
		var showAll = false;
		var paramResult = "";
		if('${paramResult}'){
			paramResult = '${paramResult}';
			$('#resultId').val(paramResult);
		}
		console.log("paramResult: "+paramResult);
		var state ="";
		var moduleId = "";
		var assignId = "";
		var authorId = "";
		$(function() {
			//加载表格
			$('#testPlanTable').bootdatagrid(
					"${pageContext.request.contextPath}/testCaseController/listTestCaseWithResult?nodeId="+nodeId
							+"&&showAll="+showAll+"&&result="+paramResult+"&&state="+state
							+"&&moduleId="+moduleId+"&&assignId="+assignId+"&&authorId="+authorId, {
						pagination : true,
						pageNumber : 1,
						pageSize : 5000,
						dataType:'json',
						singleSelect : false,
						striped : true,
						clickToSelect : true
			});

		});
		//结果列格式转换
		function resultFormatter(value,row,index){
			var results = ['活动','通过','失败','阻止','不适用'];
			return results[value];
		}
		//状态列格式转换
		function stateFormatter(value,row,index){
			var stateName = '';
			if(value == 1){
				stateName = "就绪";
			}else if(value == 2){
				stateName = "设计";
			}else if(value == 3){
				stateName = "已关闭";
			}
			return stateName;
		}
		//操作列列格式转换
		function pref_btns(value,row,index){
			var btns = '';
			btns += '<a class="btn-table-cell" onclick="addOrEditTestCase('+index+');">编辑</a>';
			btns += ' | <a class="btn-table-cell" onclick="testPlan_list.removeTestCase('+index+');">删除</a>';
			return btns;
		}
		/* =========================列表部分结束 =========================== */

		/* =========================表格上方操作按钮部分开始 =========================== */
//添加按钮
$("#insert").click(function(){
	var index = -1;

	addOrEditTestCase(index);
});
var flag;
var loadFlag;
//添加或编辑模块
function addOrEditTestCase(index){
	loadFlag = 0;
	setTimeout(function() {
		$(".fixed-table-container tbody tr[data-index='"+index+"']").addClass("selected");
	}, 50);
	flag = index;
	//没有登录信息//用户为普通用户则无法编辑
		layer.open({
			type : 2,
			title : (index != -1) ? '编辑用例' : '添加用例',
			fix : true,
			scrollbar : false,
			area : [ '1000px', '600px' ],
			shift : 2,
			content : '${pageContext.request.contextPath}/testCaseController/addOrEditTestCase',
			btn: ['确定', '取消'],
				yes : function(index, layer) {
		            var iframeWin = layer.find('iframe')[0];
		            iframeWin.contentWindow.submit();
		        },
		        btn2:function(index, layer) {
		        },
	        success: function(layero, index){
				if(!$('.layui-layer-title').has('span').length){
					 $(".layui-layer-title").prepend("<span class='glyphicon glyphicon-th-large' ></span>&nbsp;");
				 }
		  	},
			end : function(){
				if(loadFlag == 1){
					var params={
				            silent: true,
				            url:path+"/testCaseController/listTestCaseWithResult?nodeId="+nodeId
									+"&&showAll="+showAll+"&&result="+paramResult+"&&state="+state
									+"&&moduleId="+moduleId+"&&assignId="+assignId+"&&authorId="+authorId
				    };
					$('#testPlanTable').bootstrapTable('refresh',params);
					testPlan_list.listTestCaseWithResultPramList();
					testPlan_grid.initTestCaseGrid();
				}
			}
		});

};
//添加现有测试用例按钮触发
var addExistingTestCaseFlag = 0;
function addExistingTestCase(){
	addExistingTestCaseFlag = 0;
		layer.open({
			type : 2,
			title : '<span class="glyphicon glyphicon-th-large" ></span>&nbsp;添加现有测试用例',
			fix : true,
			scrollbar : false,
			area : [ '920px', '700px' ],
			shift : 2,
			content : '${pageContext.request.contextPath}/testPlanController/addExistingTestCase',
			btn: ['确定', '取消'],
				yes : function(index, layer) {
		            var iframeWin = layer.find('iframe')[0];
		            iframeWin.contentWindow.submit();
		        },
		        btn2:function(index, layer) {
		        },
			end : function(){
				if(addExistingTestCaseFlag == 1){
					var params={
				            silent: true,
				            url:path+"/testCaseController/listTestCaseWithResult?nodeId="+nodeId
									+"&&showAll="+showAll+"&&result="+paramResult+"&&state="+state
									+"&&moduleId="+moduleId+"&&assignId="+assignId+"&&authorId="+authorId
				    };
					$('#testPlanTable').bootstrapTable('refresh',params);
					testPlan_list.listTestCaseWithResultPramList();
					testPlan_grid.initTestCaseGrid();
				}
			}
		});
};
//创建bug按钮触发
function createBug(){
//		flag = index;
	//没有登录信息//用户为普通用户则无法编辑
		layer.open({
			type : 2,
			title : '创建bug',
			fix : true,
			scrollbar : false,
			area : [ '750px', '520px' ],
			shift : 2,
			content : '${pageContext.request.contextPath}/testCaseController/createBug',
			btn: ['确定', '取消'],
				yes : function(index, layer) {
		            var iframeWin = layer.find('iframe')[0];
		            iframeWin.contentWindow.submit();
		        },
		        btn2:function(index, layer) {
		        },
	        success: function(layero, index){
				if(!$('.layui-layer-title').has('span').length){
					 $(".layui-layer-title").prepend("<span class='glyphicon glyphicon-th-large' ></span>&nbsp;");
				 }
		  	},
			end : function(){

			}
		});

};
/* =========================表格上方操作按钮部分结束 =========================== */


	/* =========================网格部分开始 =========================== */
	//定义暂存全部网格数据的全局变量
	var gloabalGridData = [];
	var insertRowFlag = 0;
	var blankLineFlag = 0;
	var pastRowLen = 0;
	var pastStepLen = 0;
	var tooLongFlag = 0;
	//定义存储选中行数据的全局变量
	var getSelections = [];

	var delCaseList = [];
	//获取浏览器类型
	var myBrowser = testPlan_grid.myBrowser();
	  //新添加一行的样式
    var insertCaseTr = "<tr ondblclick='testPlan_grid.doubleClick();'>"
								    +"<td onblur='testPlan_grid.loseFocus(this);' class='editable insertRow' testcaseId=' ' nodeOrder=' '></td>"
								    +"<td onblur='testPlan_grid.loseFocus(this);' class='editable'></td>"
								    +"<td onblur='testPlan_grid.loseFocus(this);' class='editable'></td>"
								+"</tr>";
	var insertStepTr = "<tr ondblclick='testPlan_grid.doubleClick();'>"
									+"<td class='tdcolor insertStepRow' stepNumber=' '></td>"
									+"<td onblur='testPlan_grid.loseFocus(this);' class='editable'></td>"
									+"<td onblur='testPlan_grid.loseFocus(this);' class='editable'></td>"
							    +"</tr>";

	/* =========================网格部分结束 =========================== */

		/* =========================ctrl键shift键多选开始 =========================== */
		//判断ctrl键shift键单独按下
        var ctrlKey = false;
        var shiftKey = false;
        $(document).keydown(function(e){
        	if( e.ctrlKey  == true  ){  //判断ctrl键按下
        		if (e.keyCode != 17){
        			if (e.keyCode==65) {//ctrl+a
        				return false;
        			}
        			ctrlKey = false; //如果不止按了ctrl键，则不能进行多选行
        		} else{
        			ctrlKey = true;
        		}
        	}
        	if( e.shiftKey  == true  ){  //判断shift键按下
        		if (e.keyCode != 16){
        			shiftKey = false; //如果不止按了shiftKey键
        		} else{
        			shiftKey = true;
        		}
        	}
        });


        //判断ctrl键shift键 松开
        $(document).keyup(function(e){
             if (e.ctrlKey  == false && e.keyCode == 17) {//ctrl键松开
            	 ctrlKey = false;
             }
             if (e.shiftKey  == false && e.keyCode == 16) {//shift键松开
            	 shiftKey = false;
             }
        });
        /* =========================ctrl键shift键多选结束 =========================== */

        /* =========================ctrl+c复制和ctrl+v粘贴开始 =========================== */
        //先判断浏览器，在进行粘贴操作
        if(myBrowser == "IE"){
        	$(document).keydown(function(e){
            	// ctrl + v监听事件
            	if( e.ctrlKey  == true && e.keyCode == 86 ){
//             		getClipboard();
            	}
            });
        }else{
        	//获取页面键盘ctrl+v的动作
            $(document).bind('paste', function (e) {
             	//获得html类型的数据
             	var data  = e.originalEvent.clipboardData.getData("text/html");
             	$.each($(data),function (item){//对每个元素判断标签名，是否存在table
             		var element = $(data)[item];
             		var tagName = element.tagName;
             		if (tagName != undefined && tagName != null) {
             			if (tagName == "TABLE") {//粘贴的内容存在表格
             				var trs = element.getElementsByTagName('tr');//找到表中的tr
             				if(trs.length > 0){
             					testPlan_grid.traverseExeclTr(trs);
             				}
             			}
             		}
             	});
            });

        	//获取ctrl+c事件      //clipboardData.setData("Text","3333333333");
        	$(document).bind('copy', function (e) {
//         		var data  = e.originalEvent.clipboardData.getData("text/plain");

        	});

        }
        /* =========================ctrl+c复制和ctrl+v粘贴结束 =========================== */



</script>
</body>
</html>

